<?php 
namespace app\admin\controller;

use think\Controller;
use app\model\Picture;

class Picturedo extends Controller{

	// 上传商品图片
	public function addPicture(){
		$file = request()->file('file');
		if($file){
	        $info = $file->move(ROOT_PATH . 'public' . DS . 'static' . DS . 'uploads');
	        if($info){
	        	$pars['picture_id'] = getId();
	        	$pars['picture_address'] = '/DianZhuanJin/public/static/uploads/'.$info->getSaveName();
	        	$picture = Picture::create($pars);
	            return getResponse(0,$picture);
	        }else{
	            return getResponse(1,"图片上传失败");
	        }
	    }
	    return getResponse(1,"未获取图片");
	}

}


 ?>